﻿@inherits AdminCompontentBase
<MCard Class="@($"d-flex flex-column px-4 pb-3 rounded-3")" MinHeight=Height>
    <MCardTitle Class="pa-0">
        <MListItem Class="pa-0">
            <MListItemTitle Class="emphasis--text h8">
                @WebHook.DisplayName
            </MListItemTitle>
            <MListItemIcon>
                <MButton Class="mr-3" Icon OnClick="HandleEdit">
                    <SIcon Size=20 Color="emphasis2">@IconConstants.Update</SIcon>
                </MButton>
                <MButton Class="mr-3" Icon OnClick="HandleTest">
                    <SIcon Size=20 Color="emphasis2">mdi-bug</SIcon>
                </MButton>
            </MListItemIcon>
        </MListItem>
    </MCardTitle>
    <MCardText Class="flex-grow-1 pa-0">
        <div class="fill--text body2 emphasis2 px-4 py-2 text-justify rounded-2 text-truncate">
            @WebHook.Url
        </div>
    </MCardText>
    <MCardActions Class="pb-3">
        <MSpacer />
        <span class="caption regular3--text">@WebHook.ModifierName</span>
        <span class="d-flex px-1" style="height: 8px">
            <MDivider Vertical />
        </span>
        <span class="caption regular--text">@WebHook.ModificationTime.Humanize(culture:I18n.Culture) </span>
    </MCardActions>
</MCard>

@code {
    [Parameter]
    public int Height { get; set; } = 147;

    [EditorRequired]
    [Parameter]
    public WebHookListViewModel WebHook { get; set; } = null!;

    [Parameter]
    public EventCallback OnEdit { get; set; }

    [Parameter]
    public EventCallback OnTest { get; set; }

    private async Task HandleEdit()
    {
        if (OnEdit.HasDelegate)
        {
            await OnEdit.InvokeAsync();
        }
    }

    private async Task HandleTest()
    {
        if (OnTest.HasDelegate)
        {
            await OnTest.InvokeAsync();
        }
    }
}